import cv2.cv as cv
import time


## main program

cv.NamedWindow("fm_camera", 1)
capture = cv.CaptureFromCAM(1)
my_width=1280
my_height=720

cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT, my_height)
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH, my_width)
cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_FORMAT, cv.IPL_DEPTH_32F)

img = cv.QueryFrame(capture)

print "Got frame of dimensions (", img.width, " x ", img.height, ")"
size = cv.GetSize(img)

while True:
    img = cv.QueryFrame(capture)
    disp_img = cv.CreateImage( ( size[0] / 4, size[1] / 4), img.depth, img.nChannels)
    cv.Resize(img, disp_img)
    cv.ShowImage("fm_camera", disp_img)
    if cv.WaitKey(10) == 27:
        break
cv.DestroyAllWindows()
